package springboot.common_utils;

import javax.xml.crypto.Data;
import java.util.Date;

/**
 * @author daiqiang
 * @since 2024/3/12-10:42
 */
public class JobDemo {
    public void run(){

        //定时任务逻辑
        //sendEmailReport();
        System.out.println("job execute...nice"+ new Date());
    }
   /* private void sendEmailReport() {
        // 实现发送邮件的代码
        // 发件人邮箱和密码
        final String username = "your-email@example.com";
        final String password = "your-email-password";

        // 收件人邮箱
        final String to = "recipient-email@example.com";

        // 设置邮件服务器
        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", "smtp.example.com");
        props.put("mail.smtp.port", "587");

        // 获取默认session对象
        Session session = Session.getInstance(props,
                new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(username, password);
                    }
                });

        try {
            // 创建默认的 MimeMessage 对象
            Message message = new MimeMessage(session);

            // Set From: 头部头字段
            message.setFrom(new InternetAddress(username));

            // Set To: 头部头字段
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse(to));

            // Set Subject: 头部头字段
            message.setSubject("Testing Subject");

            // 设置消息体
            message.setText("Hello, this is sample for to check send "
                    + "email using JavaMailAPI ");

            // 发送消息
            Transport.send(message);

            System.out.println("Sent message successfully....");

        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }*/

}
